import request from '@/utils/request'
import { RolePageModel, RolePageReqData } from '../model/roleModel'

//获取角色列表
export function rolePageApi(data: RolePageReqData) {
  return request<RolePageModel>({
    url: '/role/page',
    method: 'post',
    data
  })
}

//获取所有角色
export function roleListApi(data?: any) {
  return request({
    url: '/role/getAllRole',
    method: 'post',
    data
  })
}

//新增角色
export function addRoleApi(data) {
  return request({
    url: '/role/add',
    method: 'post',
    data
  })
}

//修改角色
export function editRoleApi(data) {
  return request({
    url: '/role/update',
    method: 'post',
    data
  })
}

//删除角色
export function delRoleApi(data) {
  return request({
    url: '/role/del',
    method: 'post',
    data
  })
}

//角色授权
export function editRoleFuncApi(data) {
  return request({
    url: '/role/setPermi',
    method: 'post',
    data
  })
}

// 获取角色所有菜单
export function roleAllFuncApi(data: {
  roleCode?: string
  isAllMenu?: boolean
}) {
  return request({
    url: '/menu/getMenu',
    method: 'post',
    data
  })
}
